package com.wangjw.springbootdemo.service.impl;

import com.wangjw.springbootdemo.service.IDemoService;
import com.wangjw.springbootdemo.task.TestTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by wangjw on 18/10/8.
 */
@Service("iDemoService")
public class DemoServiceImpl implements IDemoService {

    private static final Logger logger = LoggerFactory.getLogger(TestTask.class);

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Override
    @Async
    public void doDemo() {
        try {
            Thread.sleep(5000);
            logger.info("当前时间：{}", dateFormat.format(new Date()));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
